use markdown_parser::parse;

#[test]
fn test_markdown_italic() {
    let input = "*4[s]4*\n";
    let (res, errs) = parse(input);
    if let Some(errs) = errs {
        panic!("{}", errs)
    }
    if let Some(res) = res {
        // println!("{:#?}", res);
        assert_eq!(
            res.iter()
                .map(|f| f.to_string())
                .reduce(|acc, e| format!("{acc}{e}"))
                .unwrap(),
            "<p><i>4[s]4</i></p>"
        )
    } else {
        panic!("斜体文本解析错误");
    }
}
#[test]
fn test_markdown_italic2() {
    let input = "*4[s]4\n";
    let (res, errs) = parse(input);
    if let Some(errs) = errs {
        panic!("{}", errs)
    }
    if let Some(res) = res {
        for ele in res.iter() {
            assert_eq!(ele.to_string().trim(), "<p>*4[s]4</p>")
        }
    } else {
        panic!("斜体文本解析错误");
    }
}

#[test]
fn test_markdown_italic3() {
    let input = "*\n";
    let (res, errs) = parse(input);
    if let Some(errs) = errs {
        panic!("{}", errs)
    }
    if let Some(res) = res {
        for ele in res.iter().take(1) {
            assert_eq!(ele.to_string().trim(), "<p>*</p>")
        }
    } else {
        panic!("斜体文本解析错误");
    }
}
